<script>
    function streamPublishApp(msg,hrefTitle, hrefLink, userPrompt)
    {
       
        FB.init({
            appId  : '<?= FACEBOOK_APP_ID ?>',
            status : true, // check login status
            cookie : true, // enable cookies to allow the server to access the session
            xfbml  : true,  // parse XFBML
            oauth  : true // enable OAuth 2.0
        });
        FB.ui(
        {
            method: 'stream.publish',
            message: msg,
            display: 'dialog',
            attachment: {
                name: '<?= str_replace("'","\\'",FACEBOOK_APP_NAME) ?>',
                caption: '',
                description: ('Digital banking matters to me. What\'s your take? Give your opinions here!'),
                href: hrefLink,
              
                media: [{
                        type: 'image',
                        src: 'http://www.dciapp.com/maybank/whats-your-take/fb-app/images/logo2.gif',
                        href:hrefLink
                    }]
            },
            action_links: [
                {
                    text: hrefTitle, 
                    href: '<?= FACEBOOK_PAGE_TAB_URL ?>'
                }
            ],
            user_prompt_message: userPrompt
        },
        function(response) {
            if (response && response.post_id){
                $.ajax({
                    type: "post",
                    url: 'update_share.php',
                    data: "uid=<?= $_SESSION['fb_id'] ?>&share_msg="+msg+"&share_type=fb_app",
                    success: function(data) {  
                        $('#divMsg').html(data);
                    }
                });
                    
            }
      
        }
    );
    }
    
   
    
    function share_twitter(){
        var content = 'Digital banking matters to me. What\'s your take? Give your opinions here! http://goo.gl/fBd3t ';
        window.open('http://twitter.com/home?status='+content,'<?= str_replace("'","\\'",FACEBOOK_APP_NAME) ?>','status=0,width=620,height=350,top=0,left=0');
        setTimeout("updateTweeterShare('"+content+"')",1000);	  
    }
      
      
    function updateTweeterShare(content)
    {
        $.ajax({
            type: "post",
            url: "update_share.php",
            data: "uid=<?= $_SESSION['fb_id'] ?>&share_msg="+content+"&share_type=tw_app",
            success: function(data) {  
                $('#divMsg').html(data);
            }
        });
    }
      
    
    <?
        if(SANDBOX_MODE==0){
    ?>

    FB.Event.subscribe('edge.create',
    function(response) {
        var str_pos=response.indexOf("data=");
       
        if(str_pos!=-1){
            var pid=response.substring(str_pos+5);
       
            $.ajax({
                type: "post",
                url: 'update_share.php',
                data: "uid=<?= $_SESSION['fb_id'] ?>&share_msg=liked&share_type=pic&share_with=like&pid="+pid,
                success: function(data) {  
                    $('#divMsg').html(data);
                }
            });
        }
        
        
    }
);
    (function(d, s, id) {
        var js, fjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id)) return;
        js = d.createElement(s); js.id = id;
        js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=<?= FACEBOOK_API_KEY ?>";
        fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));
    
    <? } ?>
    
 
</script>